import 'package:flutter/material.dart';

class HomeNav extends StatelessWidget {
  HomeNav({super.key, required this.navList});

  List navList = [];

  @override
  Widget build(BuildContext context) {
    return GridView(
      // 被滚到容器嵌套，布局出错就设置这个属性
      shrinkWrap: true,
      padding: EdgeInsets.all(10),
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 5,
      ),
      children: navList.map((item) {
        return Container(
          child: Column(
            children: [
              Image.network(item['imgUrl'], width: 46, height: 46),
              Text(item['text'], style: TextStyle(fontSize: 12)),
            ],
          ),
        );
      }).toList(),
    );
  }
}
